import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/select/mixin/check_box_mixin.dart';
import 'package:finance_app/src/widgets/select/mixin/radio_mixin.dart';
import 'package:flutter/material.dart';

class ReconcileRadio = ReconcileCheckBox with RadioMixin;

class ReconcileCheckBox extends StatelessWidget with CheckBoxMixin {
  final String datetime;
  final String name;
  final String code;
  final num amount;
  final bool isSelect;
  final bool isEnable;
  final bool isAdd;

  ReconcileCheckBox(
      {Key key,
      this.datetime,
      this.name,
      this.code,
      this.amount,
      this.isSelect,
      this.isEnable = true,
      String type})
      : isAdd = (type == 'in'),
        super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(
        horizontal: getDp(25),
        vertical: getDp(15),
      ),
      decoration: BoxDecoration(
        color: isEnable == false
            ? aceDarkGrayColor05
            : isSelect == true
                ? aceSelectBackgroundColor
                : null,
        border:
            Border(bottom: BorderSide(color: aceGrayColor, width: getDp(0.5))),
      ),
      child: Stack(
        children: [
          Row(
            children: [
              buildSelectWidget,
              AppSpaces.w25,
              Text(
                datetime,
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(16),
                  fontWeight: FontWeight.w400,
                  height: 22 / 16,
                ),
              ),
              AppSpaces.w15,
              Expanded(
                child: Container(
                  constraints: BoxConstraints(maxWidth: getDp(120)),
                  child: Text(
                    '$name \n$code',
                    style: TextStyle(
                      color: aceBlackColor,
                      fontSize: getSp(16),
                      fontWeight: FontWeight.w400,
                      height: 22 / 16,
                    ),
                    textAlign: TextAlign.start,
                  ),
                ),
              ),
            ],
          ),
          Positioned(
            bottom: 0.0,
            right: 0.0,
            child: Text.rich(
              TextSpan(
                  text: '${CashUtils.operation(isAdd ? 1 : -1)}',
                  style: TextStyle(
                    fontSize: getSp(16),
                    color: CashUtils.getColor(isAdd ? 1 : -1),
                    fontWeight: FontWeight.bold,
                    height: 14 / 12,
                  ),
                  children: [
                    TextSpan(
                        text: '${CashUtils.ignoreFormatCashAmount(amount)}',
                        style: TextStyle(
                          color: aceBlackColor,
                          fontSize: getSp(16),
                          fontWeight: FontWeight.w400,
                          height: 14 / 16,
                        )),
                  ]),
            ),
          )
        ],
      ),
    );
  }
}
